<template>
  <a-modal
    :width="800"
    title="表达式列表"
    :visible.sync="editModalVisible"
    @cancel="handleCancleDbSync"
    :footer="false"
    >
      <template slot="footer">
        <a-button @click="handleCancleDbSync">
          关闭
        </a-button>
        <a-button type="primary" @click="handleDbSync" >确定</a-button>
      </template>
      <s-table
        size="middle"
        bordered
        row-key="id"
        :columns="columns"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type: getType}"
        :data="loadData_"
      >
    </s-table>
    <!--  -->
  </a-modal>
</template>
<script>
import STable from '@/components/Xtable'
import { getAction } from '@/api/manage'
export default {
  name: 'ExtActExpressionListModal',
  components: {
    STable
  },
  computed: {
    // 计算属性的 getter
    getType: function() {
      return this.multi === true ? 'checkbox' : 'radio'
    }
  },
  data() {
    return {
      editModalVisible: false,
      multi: false,
      selectedRowKeys: [],
      selectionRows: [],
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '表达式名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '表达式',
          align: 'center',
          dataIndex: 'expression'
        }
      ],
      url: {
        list: '/online/cgform/api/getData/172385df5b4f4ada942a7e6c89f0b012'
      },
      queryParam: {
        pageNo: 1,
        pageSize: 10
      },
      loadData_: parameter => {
        return getAction(this.url.list, Object.assign(parameter, this.queryParam)).then(res => {
          const data = res.result
          data.pageNo = this.queryParam.pageNo
          data.pageSize = this.queryParam.pageSize
          data.current = this.queryParam.pageNo
          return data
        })
      }
    }
  },
  methods: {
    handleCancleDbSync() {
      this.editModalVisible = false
    },
    handleDbSync() {
      this.editModalVisible = false
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
    }
  }
}
</script>
<style lang="less">

</style>
